//
// Created by 匡涂上青 on 2021/6/21.
//

#include "test.h"

#include <core/file_system.h>
#include <core/log.h>

#include <string>
#include <vector>

using namespace kgl;
using std::string;

int file_system_test_main() {
    Log::Init();

    std::vector<std::pair<string, string>> test_data = {
            {"void",                     ""},
            {"only filename",            "file_name"},
            {"only pathname",            "path_name/"},  // wrong
            {"hide only filename",       ".file_name"},  // wrong with extend
            {"hide path",                ".path_name/"}, //wring
            {"without path",             "file_name.ext"},
            {"without extend_name",      "path_name/file_name"},
            {"hide without extend_name", "path_name/.file_name"},
            {"regular path_file",        "path_name/file_name.ext"},
            {"hide path_file",           "path_name/.file_name.ext"},
            {"void path",                "//file_name.ext"},
            {"with dot file",            "path_name/.f.ile..name.ext"},
            {"with dot path",            "./file_name.ext"},
    };

    for (auto&[test_name, test_str] : test_data) {
        Log::Trace("{0} test:", test_name);
        Log::Trace("get_file_name('{0}') => '{1}'", test_str, fs::get_file_name(test_str));
        Log::Trace("get_file_total('{0}') => '{1}'", test_str, fs::get_file_total(test_str));
        Log::Trace("get_file_extend('{0}') => '{1}'", test_str, fs::get_file_extend(test_str));
        Log::Trace("get_file_path('{0}') => '{1}'", test_str, fs::get_file_path(test_str));
        Log::Trace("replace_file_name('{0}') => '{1}'", test_str, fs::replace_file_name((const string) test_str, "??"));
        Log::Trace("-----------");
    }

    return 0;
}